#include<bits/stdc++.h>
using namespace std;
struct add{
    int b;
    int e;
    int num;
};

    
int main(){
    ios::sync_with_stdio(false);
    cin.tie(NULL);cout.tie(NULL);

    int n,p;
    cin>>n>>p;
    vector<int>nums(n+1);
    vector<int>d(n+1);//差分数组
    add a;

    //计算差值
    for (int  i = 1; i <=n; i++)
    {
        cin>>nums[i];
        d[i] =  nums[i]-nums[i-1];
    }

    //更新差分数组
    for (int  i = 1; i <=p; i++)
    {//输入范围 和增加数目
        cin>>a.b>>a.e>>a.num;
        d[a.b]+=a.num;
        if(a.e+1<=n)d[a.e+1]-=a.num;

    }

    int mn = INT_MAX;
    for (int  i = 1; i <=n; i++)
    {
        //更新数组
        nums[i] = nums[i-1]+d[i];
        mn = min(mn,nums[i]);
    }
    cout<<mn;
    return 0;
}